# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

all: halt matmult sort testfiles part1TestSuite exit execTest3 execTest4 execTest5 part2TestSuite part1_2TestSuite listTester doctorOffice projectPart3  p3Part3Test patient patientExec wrn cashier wrnExec cashierExec xray xrayExec doctor doctorExec nurse nurseExec execAll p4p4test1 p4p4test2

start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s

halt.o: halt.c
	$(CC) $(CFLAGS) -c halt.c
halt: halt.o start.o
	$(LD) $(LDFLAGS) start.o halt.o -o halt.coff
	../bin/coff2noff halt.coff halt

sort.o: sort.c
	$(CC) $(CFLAGS) -c sort.c
sort: sort.o start.o
	$(LD) $(LDFLAGS) start.o sort.o -o sort.coff
	../bin/coff2noff sort.coff sort

matmult.o: matmult.c
	$(CC) $(CFLAGS) -c matmult.c
matmult: matmult.o start.o
	$(LD) $(LDFLAGS) start.o matmult.o -o matmult.coff
	../bin/coff2noff matmult.coff matmult

testfiles.o: testfiles.c
	$(CC) $(CFLAGS) -c testfiles.c
testfiles: testfiles.o start.o
	$(LD) $(LDFLAGS) start.o testfiles.o -o testfiles.coff
	../bin/coff2noff testfiles.coff testfiles

part1TestSuite.o: part1TestSuite.c
	$(CC) $(CFLAGS) -c part1TestSuite.c
part1TestSuite: part1TestSuite.o start.o
	$(LD) $(LDFLAGS) start.o part1TestSuite.o -o part1TestSuite.coff
	../bin/coff2noff part1TestSuite.coff part1TestSuite	
	
doctorOffice.o: doctorOffice.c doctorOffice.h
	$(CC) $(CFLAGS) -c doctorOffice.c
doctorOffice: doctorOffice.o start.o
	$(LD) $(LDFLAGS) start.o doctorOffice.o -o doctorOffice.coff
	../bin/coff2noff doctorOffice.coff doctorOffice	
	
listTester.o: listTester.c
	$(CC) $(CFLAGS) -c listTester.c
listTester: listTester.o start.o
	$(LD) $(LDFLAGS) start.o listTester.o -o listTester.coff
	../bin/coff2noff listTester.coff listTester	
	
printTester.o: printTester.c
	$(CC) $(CFLAGS) -c printTester.c
printTester: printTester.o start.o
	$(LD) $(LDFLAGS) start.o printTester.o -o printTester.coff
	../bin/coff2noff printTester.coff printTester	
	
arrayTester.o: arrayTester.c
	$(CC) $(CFLAGS) -c arrayTester.c
arrayTester: arrayTester.o start.o
	$(LD) $(LDFLAGS) start.o arrayTester.o -o arrayTester.coff
	../bin/coff2noff arrayTester.coff arrayTester	
	
exit.o: exit.c
	$(CC) $(CFLAGS) -c exit.c
exit: exit.o start.o
	$(LD) $(LDFLAGS) start.o exit.o -o exit.coff
	../bin/coff2noff exit.coff exit	

	
execTest3.o: execTest3.c
	$(CC) $(CFLAGS) -c execTest3.c
execTest3: execTest3.o start.o
	$(LD) $(LDFLAGS) start.o execTest3.o -o execTest3.coff
	../bin/coff2noff execTest3.coff execTest3	

execTest4.o: execTest4.c
	$(CC) $(CFLAGS) -c execTest4.c
execTest4: execTest4.o start.o
	$(LD) $(LDFLAGS) start.o execTest4.o -o execTest4.coff
	../bin/coff2noff execTest4.coff execTest4	

execTest5.o: execTest5.c
	$(CC) $(CFLAGS) -c execTest5.c
execTest5: execTest5.o start.o
	$(LD) $(LDFLAGS) start.o execTest5.o -o execTest5.coff
	../bin/coff2noff execTest5.coff execTest5	

part2TestSuite.o: part2TestSuite.c
	$(CC) $(CFLAGS) -c part2TestSuite.c
part2TestSuite: part2TestSuite.o start.o
	$(LD) $(LDFLAGS) start.o part2TestSuite.o -o part2TestSuite.coff
	../bin/coff2noff part2TestSuite.coff part2TestSuite	

part1_2TestSuite.o: part1_2TestSuite.c
	$(CC) $(CFLAGS) -c part1_2TestSuite.c
part1_2TestSuite: part1_2TestSuite.o start.o
	$(LD) $(LDFLAGS) start.o part1_2TestSuite.o -o part1_2TestSuite.coff
	../bin/coff2noff part1_2TestSuite.coff part1_2TestSuite	

projectPart3.o: projectPart3.c
	$(CC) $(CFLAGS) -c projectPart3.c
projectPart3: projectPart3.o start.o
	$(LD) $(LDFLAGS) start.o projectPart3.o -o projectPart3.coff
	../bin/coff2noff projectPart3.coff projectPart3	


p3Part3Test.o: p3Part3Test.c
	$(CC) $(CFLAGS) -c p3Part3Test.c
p3Part3Test: p3Part3Test.o start.o
	$(LD) $(LDFLAGS) start.o p3Part3Test.o -o p3Part3Test.coff
	../bin/coff2noff p3Part3Test.coff p3Part3Test
	
patient.o: patient.c doctorOffice.h
	$(CC) $(CFLAGS) -c patient.c
patient: patient.o start.o
	$(LD) $(LDFLAGS) start.o patient.o -o patient.coff
	../bin/coff2noff patient.coff patient
	
patientExec.o: patientExec.c
	$(CC) $(CFLAGS) -c patientExec.c
patientExec: patientExec.o start.o
	$(LD) $(LDFLAGS) start.o patientExec.o -o patientExec.coff
	../bin/coff2noff patientExec.coff patientExec
	
wrn.o: wrn.c doctorOffice.h
	$(CC) $(CFLAGS) -c wrn.c
wrn: wrn.o start.o
	$(LD) $(LDFLAGS) start.o wrn.o -o wrn.coff
	../bin/coff2noff wrn.coff wrn
	
cashier.o: cashier.c doctorOffice.h
	$(CC) $(CFLAGS) -c cashier.c
cashier: cashier.o start.o
	$(LD) $(LDFLAGS) start.o cashier.o -o cashier.coff
	../bin/coff2noff cashier.coff cashier
	
wrnExec.o: wrnExec.c
	$(CC) $(CFLAGS) -c wrnExec.c
wrnExec: wrnExec.o start.o
	$(LD) $(LDFLAGS) start.o wrnExec.o -o wrnExec.coff
	../bin/coff2noff wrnExec.coff wrnExec

cashierExec.o: cashierExec.c
	$(CC) $(CFLAGS) -c cashierExec.c
cashierExec: cashierExec.o start.o
	$(LD) $(LDFLAGS) start.o cashierExec.o -o cashierExec.coff
	../bin/coff2noff cashierExec.coff cashierExec

xray.o: xray.c doctorOffice.h
	$(CC) $(CFLAGS) -c xray.c
xray: xray.o start.o
	$(LD) $(LDFLAGS) start.o xray.o -o xray.coff
	../bin/coff2noff xray.coff xray

xrayExec.o: xrayExec.c
	$(CC) $(CFLAGS) -c xrayExec.c
xrayExec: xrayExec.o start.o
	$(LD) $(LDFLAGS) start.o xrayExec.o -o xrayExec.coff
	../bin/coff2noff xrayExec.coff xrayExec
	
doctor.o: doctor.c doctorOffice.h
	$(CC) $(CFLAGS) -c doctor.c
doctor: doctor.o start.o
	$(LD) $(LDFLAGS) start.o doctor.o -o doctor.coff
	../bin/coff2noff doctor.coff doctor
	
doctorExec.o: doctorExec.c
	$(CC) $(CFLAGS) -c doctorExec.c
doctorExec: doctorExec.o start.o
	$(LD) $(LDFLAGS) start.o doctorExec.o -o doctorExec.coff
	../bin/coff2noff doctorExec.coff doctorExec
	
nurse.o: nurse.c doctorOffice.h
	$(CC) $(CFLAGS) -c nurse.c
nurse: nurse.o start.o
	$(LD) $(LDFLAGS) start.o nurse.o -o nurse.coff
	../bin/coff2noff nurse.coff nurse

nurseExec.o: nurseExec.c
	$(CC) $(CFLAGS) -c nurseExec.c
nurseExec: nurseExec.o start.o
	$(LD) $(LDFLAGS) start.o nurseExec.o -o nurseExec.coff
	../bin/coff2noff nurseExec.coff nurseExec
	
execAll.o: execAll.c
	$(CC) $(CFLAGS) -c execAll.c
execAll: execAll.o start.o
	$(LD) $(LDFLAGS) start.o execAll.o -o execAll.coff
	../bin/coff2noff execAll.coff execAll	

p4p4test1.o: p4p4test1.c
	$(CC) $(CFLAGS) -c p4p4test1.c
p4p4test1: p4p4test1.o start.o
	$(LD) $(LDFLAGS) start.o p4p4test1.o -o p4p4test1.coff
	../bin/coff2noff p4p4test1.coff p4p4test1

p4p4test2.o: p4p4test2.c
	$(CC) $(CFLAGS) -c p4p4test2.c
p4p4test2: p4p4test2.o start.o
	$(LD) $(LDFLAGS) start.o p4p4test2.o -o p4p4test2.coff
	../bin/coff2noff p4p4test2.coff p4p4test2
	
clean:
	rm -f *.o *.coff
